package example;

import db.domain.User;
import sf.database.OrmContext;
import sf.dsl.Example;
import sf.dsl.ExampleSQLHelp;

import java.util.List;
import java.util.function.Function;

public class TExample {
    public static void main(String[] args) {
        System.out.println(TExample.class.getName().replace(".", "/"));


        Example example = new Example(User.class);
        example.createCriteria().eq(User.Field.id, 1).and().leftP().isNotNull(User.Field.sex).or().isNull(User.Field.displayName).rightP();
        example.orderBy(User.Field.id, Example.Order.DESC).orderBy(User.Field.displayName, Example.Order.DESC);
        List<Example.Criteria> list = example.getCriterias();

        OrmContext context = ExampleSQLHelp.getOrmContextWhereClause(example,false);

        System.out.println(context.getSql());
        System.out.println(example.getOrderByClause(false));
        int[] arr = new int[10];
        for (int a : arr) {
            System.out.println(a);
        }

        int i = 0;
        System.out.println(Integer.valueOf(i) == null);

        Example e2 = new Example(User.class);
        e2.selectProperties(User.Field.id).createCriteria()
                .eq(User.Field.id, 1).getExample()
                .orderByAsc(User.Field.id);
        context = ExampleSQLHelp.getOrmContextWhereClause(example,false);
        System.out.println(context.getSql());


    }

    private void t() {
        Function fn = o -> ((User) o).getUrl();
    }
}
